package model.doe;

public class Prism extends AbstractDoe {

	private static double doeHeight;
	private static double doeWidth;
	private static double n;
	private static double a;
	private static double wl;
	private static double doeStep;
	private double aa;
	private double s;
	private double p;
	private double c;
	private double tg;
	private double u0;

	public Prism (double doeHeight, double doeWidth, double n, double a, double wl, double doeStep){
		this.doeHeight=doeHeight;
		this.doeWidth=doeWidth;
		this.n=n;
		this.a=a;
		this.wl=wl;
		this.doeStep=doeStep;
		super.widthPointsNumber = (int) (doeWidth / 2 / doeStep);
		super.heightPointsNumber = (int) (doeHeight / 2 / doeStep);
		
		
		this.aa = a*Math.PI/180;
		this.s=Math.sin(aa);
		this.c = Math.cos(aa);
		this.p = 1-n*n*s*s;
		this.tg = (2*Math.PI*1000/wl)*s*(n*c-Math.sqrt(p));
		this.u0= doeWidth/2;
		super.maximumValue = 2*tg*u0;		
	}
	
	private double calculate (double u){
		return tg*(u+u0);
	}

	@Override
	public double run(int i, int j) {		
		return calculate(doeStep * i);
	}

}
